package com.pzr.soccer.aop.metric;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class MetricAspect {
   private Logger lg=LoggerFactory.getLogger("Metric");
	@Around("@annotation(metricTime)")
	public Object metric(ProceedingJoinPoint pj, MetricTime metricTime) {
		
		long start = System.currentTimeMillis();
		try {
			return pj.proceed();
		} catch (Throwable e) {
			e.printStackTrace();
			return null;
		} finally {
			long end = System.currentTimeMillis();
			lg.info(pj.getSignature().getName()+" cost " + (end - start)+ "ms");
		}

	}
}
